//邮箱和手机号验证
export const regx = (type) =>{
	var verify = '';
	switch(type){
		case 'email':
			verify = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
			break;
		case 'password':
			verify = /^(?:(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*?_()])).{6,18}$/;
			break;
		case 'phone':
			verify = /^(12[0-9]|13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9]|19[0-9])\d{8}$/;
			break;
		default:
			break;
	};
	return verify;
}
//时间戳转时间精确到时分秒
export const detailTime = (value) =>{
	if (value == 0 || value == null || value == '') {
		return '-';
	}
	var date = new Date(value * 1000);
	var Y = date.getFullYear();
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
	var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
	var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
	var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
	return Y + '-' + M + '-' + D + ' ' + h + ':' + m + ':' + s
}
//时间戳转时间精确年月日 (新增)
export const detailDataTime = (value) =>{
	if (value == 0 || value == null || value == '') {
		return '-';
	}
	var date = new Date(value * 1000);
	var Y = date.getFullYear();
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
	var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
	// var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
	// var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	// var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
	return Y + '-' + M + '-' + D 
}
//年月日日期格式
export const detailDataTimeWord = (value) =>{
	if (value == 0 || value == null || value == '') {
		return '-';
	}
	var date = new Date(value * 1000);
	var Y = date.getFullYear();
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
	var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
	// var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
	// var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	// var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
	return Y + '年' + M + '月' + D + '日'
}
//时间戳转时间精确到日期
export const detailTimeDate = (value,type) =>{
	// console.log('type:' + type + ',value:' + value);
	if (value == 0 || value == null  || value == '') {
		return '-';
	}
	var date = new Date(value*1000);
	var Y = date.getFullYear();
	var M =  date.getMonth() + 1;
	var D =  date.getDate();
	if(type == 'short'){
		return M + '.' + D
	}else {
		return  M + '月' + D + '日'

	} 
}

//时间戳转时间精确到时分
export const detailTimeSceond = (value) =>{
	if (value == 0 || value == null  || value == '') {
		return '-';
	}
	var date = new Date(value * 1000);
	var Y = date.getFullYear();
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
	var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
	var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
	var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
	return   h + ':' + m + ':' + s
}

//时间戳转时间精确到日时分
export const detailTimeDaySceond = (value) =>{
	if (value == 0 || value == null  || value == '') {
		return '-';
	}
	var date = new Date(value * 1000);
	var Y = date.getFullYear();
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
	var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
	var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
	var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
	return   M +'/'+ D + ' ' + h  + ':' + m + ':' + s
}